<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="../js/jquery.2.1.4.js"></script>
</head>
<script>
    $(function () {
        $("#username").change(function () {
            $("#tip1").html("");
            var name = $("#username").val().trim();
            if (name != "") {
                $.post("/erp/userCtrl?parm=check", {username: name}, function (data) {
                    if (data == 1) {
                        $("#tip1").html("用户名已经存在");
                    }
                })
            }
        });

    });

    function valid() {
        var flag = false;
        if ($("#tip1").html() != "") {
            $("#tip2").html("");
            return false;
        }
        $("#tip1").html("");
        $("#tip2").html("");
        if ($("#username").val().trim() == "") {
            $("#tip1").html("用户名不能为空");
            flag = true;
        }
        if ($("#nickName").val().trim() == "") {
            $("#tip2").html("昵称不能为空")
            flag = true;
        }
        if (flag) {
            return false;
        }

    }
</script>
<body>
<fieldset style="width:350px; margin: 50px auto;border: hidden">
    <form action="${pageContext.request.contextPath}/userCtrl?parm=add" method="post">
        用户名：<input id="username" type="text" name="username"><span id="tip1" style="color: red"></span><br><br>
        昵&nbsp;&nbsp;&nbsp;称：<input id="nickName" type="text" name="nickName"><span id="tip2" style="color: red"></span><br><br>
        <input type="checkbox" name="isAdmin">管理员
        <input type="checkbox" name="state">禁&nbsp;&nbsp;用
        <input type="checkbox" name="deleted">删&nbsp;&nbsp;除<br><br>
        <input type="submit" value="添加" onclick="return valid();"/>
    </form>
</fieldset>
</body>
</html>
